﻿using UnityEngine;
using System.Collections;

public enum RowPosition { FRONT, BACK };

public class Position : MonoBehaviour {
	public RowPosition rowPosition;
	public float verticalMoveAmount;
	public float speed;
	public bool moving;
	bool direction;
	Vector3 original, up, down;
	// Use this for initialization
	void Start () {
		direction = true;
		original = transform.position;
		up = new Vector3 (original.x, original.y + verticalMoveAmount, original.z);
		down = new Vector3 (original.x, original.y - verticalMoveAmount, original.z);
	}
	
	// Update is called once per frame
	void Update () {
		if(moving) {
			if(direction) {
				if(Vector3.Distance(transform.position, up) > 1f) {
					transform.position = Vector3.MoveTowards(transform.position, up, speed * Time.deltaTime);
				} else {
					direction = false;
				}
			} else {
				if(Vector3.Distance(transform.position, down) > 1f) {
					transform.position = Vector3.MoveTowards(transform.position, down, speed * Time.deltaTime);
				} else {
					direction = true;
				}
			}
		} else {
			transform.position = Vector3.MoveTowards(transform.position, original, speed * Time.deltaTime);
		}
	}
}
